package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsSearchHistoryMapper;
import com.qf.pojo.DtsSearchHistory;
import com.qf.service.DtsSearchHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author bss
 * @version V1.0
 * @Project maven
 * @Package com.qf.service.impl
 * @Description:
 * @Date 2022/10/16 22:27
 */
@Service
public class DtsSearchHistoryServiceImpl implements DtsSearchHistoryService {

    @Autowired
    DtsSearchHistoryMapper searchHistoryMapper;
    @Override
    public Map<String, Object> selectByPage(Integer page, Integer limit, String sort, String order, Integer userId, String keyword) {

        List<DtsSearchHistory> list = searchHistoryMapper.selectByPage(page,limit,sort,order,userId,keyword);

        LambdaQueryWrapper<DtsSearchHistory> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsSearchHistory::getDeleted,false);
        int count = searchHistoryMapper.selectCount(wrapper);
        Map<String, Object> data = new HashMap<>();
        data.put("total", count);
        data.put("items", list);
        return data;
    }
}
